package cloud.xlh.middleware_manage.enums;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2023/2/27 16:38
 * @ Description: 中间件类型
 */
public enum TypeEnums {
    MYSQL(000, "mysql"),
    REDIS(001, "redis"),
    CANAL(010, "canal"),
    RABBITMQ(011, "rabbitmq");

    private static final Set<Integer> enumSet = new HashSet<>(4);

    static {
        Arrays.asList(OpTypeEnum.values()).forEach(e -> enumSet.add(e.getCode()));
    }

    public static boolean hasEnum(Integer code) {
        return enumSet.contains(code);
    }


    private Integer code;

    private String desc;

    TypeEnums(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(Integer code) {
        TypeEnums[] values = values();
        if (code == null)
            return null;
        for (TypeEnums value : values) {
            if (value.code.equals(code)) {
                return value.desc;
            }
        }
        return null;
    }
}
